//
//  RefundVC.m
//  phmall
//
//  Created by admin on 2017/10/14.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "RefundVC.h"
#import "OrderEvaluationView.h"
#import "OrderCell.h"
#import "EvaluateText.h"
#import "ScoringView.h"
@interface RefundVC ()<UITableViewDelegate,UITableViewDataSource,UIGestureRecognizerDelegate,UIActionSheetDelegate>
@property(strong,nonatomic)UITableView *myTableview;
@end

@implementation RefundVC
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    UIBarButtonItem *leftBar=[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"返回-1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleDone target:self action:@selector(leftBarAction)];
    self.navigationItem.leftBarButtonItem=leftBar;
    [self.view addSubview:self.myTableview];
    [self.myTableview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(0);
        make.left.right.equalTo(self.view).priorityHigh();
        make.bottom.equalTo(self.view).with.offset(0).priorityHigh();
    }];
    
    // Do any additional setup after loading the view.
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 1;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 330;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 54;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 330)];
    view.backgroundColor=[UIColor groupTableViewBackgroundColor];
    
    UIView *back=[[UIView alloc]init];
    back.backgroundColor=[UIColor whiteColor];
    [view addSubview:back];
    [back mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(view);
        make.left.equalTo(view).offset(0);
        make.right.equalTo(view).offset(0);
        make.height.offset(160);
    }];
    
    EvaluateText *textView=[[EvaluateText alloc]init];
    textView.placeholder=@"在这里留下你的想法吧~~~";
    [back addSubview:textView];
    [textView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(back);
        make.left.equalTo(back).offset(10);
        make.right.equalTo(back).offset(-10);
        make.height.offset(160);
    }];
    
    UIView *causeView=[[UIView alloc]init];
    causeView.backgroundColor=[UIColor whiteColor];
    [view addSubview:causeView];
    [causeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(back);
        make.top.equalTo(textView.mas_bottom).offset(1);
        make.height.offset(40);
    }];
    
    UILabel *select=[[UILabel alloc]init];
    select.text=@"请选择退款原因";
    select.font=[UIFont systemFontOfSize:12];
    [view addSubview:select];
    [select mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(causeView).offset(10);
        make.centerY.equalTo(causeView);
    }];
    
    UIImageView *img=[[UIImageView alloc]init];
    img.image=[UIImage imageNamed:@"前往"];
    [view addSubview:img];
    [img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(causeView).offset(-10);
        make.centerY.equalTo(causeView);
        make.height.offset(15);
        make.width.offset(15);
    }];

    UITapGestureRecognizer * causeTap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAvatarView:)];
    causeTap.numberOfTouchesRequired = 1; //手指数
    causeTap.numberOfTapsRequired = 1; //tap次数
    causeTap.delegate= self;
    [causeView addGestureRecognizer:causeTap];

    return view;
}
#pragma mark - ActionSheet Delegate


-(void)tapAvatarView:(UITapGestureRecognizer *)tap{
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    [alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        NSLog(@"点击取消");
    }]];
    [alertController addAction:[UIAlertAction actionWithTitle:@"我不想买了" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        NSLog(@"点击确认");
    }]];
    [alertController addAction:[UIAlertAction actionWithTitle:@"信息填错,重新拍" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        NSLog(@"点击确认");
    }]];
    [alertController addAction:[UIAlertAction actionWithTitle:@"卖家迟迟不发货" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        NSLog(@"点击确认");
    }]];
    [alertController addAction:[UIAlertAction actionWithTitle:@"误点错拍" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        NSLog(@"点击确认");
    }]];
    [alertController addAction:[UIAlertAction actionWithTitle:@"其他原因" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        NSLog(@"点击确认");
    }]];

    [self.navigationController presentViewController:alertController animated:YES completion:nil];
    
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 44)];
    view.backgroundColor=[UIColor groupTableViewBackgroundColor];
    
    UIView* back=[[UIView alloc]init];
    back.backgroundColor=[UIColor whiteColor];
    [view addSubview:back];
    [back  mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(view);
        make.top.equalTo(view).offset(10);
        make.bottom.equalTo(view.mas_bottom);
    }];
    
    UILabel *title=[[UILabel alloc]init];
    [back addSubview:title];
    title.text=@"退款说明:";
    title.font=[UIFont systemFontOfSize:16];
    [title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(back).offset(10);
        make.centerY.equalTo(back);
    }];
    
    UIView *line=[[UIView alloc]init];
    line.backgroundColor=[UIColor groupTableViewBackgroundColor];
    [view addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(view).offset(0);
        make.right.equalTo(view).offset(0);
        make.bottom.equalTo(view);
        make.height.offset(1);
    }];
    
    return view;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    OrderCell *cell=[OrderCell theShareCellWithTableView:tableView];
    //    OrderModel *model=self.orderList[indexPath.section];
    //    NSMutableArray *data=model.goods_list;
    //    GoodsListModel *goodsModel=data[indexPath.row];
    //    cell.model=goodsModel;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    //分割线补全
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
}
//MARK:-GETTER
- (UITableView *)myTableview{
    if (!_myTableview) {
        _myTableview = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _myTableview.delegate = self;
        _myTableview.dataSource = self;
        _myTableview.backgroundColor=[UIColor groupTableViewBackgroundColor];
        _myTableview.separatorStyle = UITableViewCellSeparatorStyleNone;
        _myTableview.showsVerticalScrollIndicator=NO;
        //        _myTableview.emptyDataSetSource=self;
        //        _myTableview.emptyDataSetDelegate=self;
        _myTableview.scrollEnabled = YES;
    }
    return _myTableview;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
